<?php
namespace Home\Controller;
use Think\Controller;
class PublicController extends \Think\Controller {
    public function doLogin() {
       $where['uname'] = I('post.uname');
       $where['upass'] = md5(I('post.upass'));
       $user = D('User');
       $res = $user->findOne($where);
       if (!$res) {
           $this->error('登录失败，用户名或密码错误',U('Public/login'),2);
       }
       session('user', $res);
       $this->redirect('Index/index');
    }
    public function adminLogin() {
       if ('wanzhao' != I('post.uname') || '94482f577055f65ad58dfaa7871a0417' != md5(I('post.upass'))) {
           $this->error('登录失败，用户名或密码错误',U('Public/adlogin'),2);
       }
       session('admin', array('uname'=>'wanzhao','logtime'=>time()));
       $this->redirect('Adduser/index');
    }
    public function logout() {
        $_SESSION = array();
        $this->redirect('Index/index');
    }
}

